<%@page import="com.alibaba.fastjson.JSON"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.alibaba.fastjson.JSONArray"%>
<%@page import="weaver.general.Util"%>
<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/mobile/plugin/westvalley/common/jsp/HttpClientCommon.jsp" %>
<%
boolean isFlag = false;
String msg = "";
try{
	String url = Util.null2String(request.getParameter("url"));
	int connTimeOut = Util.getIntValue(request.getParameter("connTimeOut"));
	int readTimeOut = Util.getIntValue(request.getParameter("readTimeOut"));
	String headerParams = Util.null2String(request.getParameter("headerParams"));
	String formParams = Util.null2String(request.getParameter("formParams"));
	String bodyContentType = Util.null2String(request.getParameter("bodyContentType"));
	String bodyParams = Util.null2String(request.getParameter("bodyParams"));
	msg = post(url,"UTF-8",getMap(headerParams),getMap(formParams),bodyParams,bodyContentType,readTimeOut,connTimeOut);
	isFlag = true;
}catch(Exception e){
	isFlag = false;
	msg = e.getMessage(); 
}

JSONObject result = new JSONObject();
result.put("isFlag",isFlag);
result.put("msg",msg);
out.print(result.toJSONString());
%>

<%!

private Map<String,String> getMap(String str){
	Map<String,String> map = new HashMap<String,String>();
	JSONArray arr = JSON.parseArray(str);
	if( arr!=null ){
		for(int i=0;i<arr.size();i++){
			JSONObject json = arr.getJSONObject(i);
			map.put(json.getString("name"),json.getString("value"));
		}
	}
	return map;
}

%>
